package com.platform.dao.mybatis;

import com.platform.dao.ComboboxDao;
import com.platform.dao.mybatis.mapper.ComboboxMapper;
import com.platform.domain.TbSysCodeClass;
import com.platform.domain.TbSysDepartment;
import com.platform.domain.result.ComboboxData;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: wangyanginfo
 * Date: 12-9-11
 * Time: 下午3:41
 * To change this template use File | Settings | File Templates.
 */
@Service("comboboxDao")
public class ComboboxDaoImpl implements ComboboxDao {

    @Resource
    private ComboboxMapper comboboxMapper;

    /**
     * 查询下拉框结构的机构信息
     *
     * @param superiorDeptId 上级机构ID
     * @return 机构信息列表
     */
    @Override
    public List<ComboboxData> queryDepts(String superiorDeptId) throws Exception {
        TbSysDepartment tbSysDepartment = new TbSysDepartment();
        tbSysDepartment.setDeptSuperior(superiorDeptId);
        return comboboxMapper.queryDeptsByDeptSupperior(tbSysDepartment);
    }

    /**
     * 根据字典类型查询字典信息
     *
     * @param classId 字典类型
     * @return 字典信息列表
     */
    @Override
    public List<ComboboxData> queryDicts(String classId) throws Exception {
        TbSysCodeClass tbSysCodeClass = new TbSysCodeClass();
        tbSysCodeClass.setClassId(classId);
        return comboboxMapper.queryDictsByClassId(tbSysCodeClass);
    }
}
